﻿Imports System.Data.OleDb
Imports System.Web.UI.WebControls
Imports System.Web
Public Class StoryBoard
    Inherits System.Web.UI.Page


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim conn = New OleDbConnection(ConfigurationManager.ConnectionStrings _
                ("MovieConnectionString").ToString())

        Dim comments As Integer = 1
        'Dim user1 = Request.QueryString("userid")
        Dim str = "select UserID from aspnet_Users where UserName='" & User.Identity.Name & "'"
        Dim cmd1 As New OleDbCommand(str, conn)
        conn.Open()
        Dim id As OleDbDataReader = cmd1.ExecuteReader
        id.Read()
        Dim UserID As Integer = id("UserID")

        Dim sql As String = "INSERT INTO StoryBoard (Userid,Topics,CreatedDate,Description,NoComments) VALUES (@Userid, @Topics, @CreatedDate, @Description, @NoComments)"
        Dim cmd As New OleDbCommand(sql, conn)
        cmd.Parameters.AddWithValue("@Userid", UserID)
        cmd.Parameters.AddWithValue("@Topics", TextBox1.Text)
        cmd.Parameters.AddWithValue("@CreatedDate", Date.Now.Date)
        cmd.Parameters.AddWithValue("@Description", TextBox2.Text)
        cmd.Parameters.AddWithValue("@NoComments", comments)
        cmd.ExecuteNonQuery()
        conn.Close()
        TextBox1.Text = ""
        TextBox2.Text = ""
        GridView1.DataBind()
    End Sub

End Class